home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 009a / ru01.zip / READXGF.C < prev    next >
C/C++ Source or Header  |  1993-06-11  |  1KB  |  61 lines

  1. /* ************************************************************* */
  2. /* readxgf.c For Turbo C - Demonstrates how to display XGF files */
  3. /*                         that are 64K or less. Use disxgf.c    */
  4. /*               for files that are greater than 64K   */
  5. /*                                                               */
  6. /* Use Raster Clip/Rastport to convert PCX files to XGF format.  */
  7. /*                                                               */
  8. /* ************************************************************* */
  9.  
  10. #include <stdio.h>
  11. #include <alloc.h>
  12. #include <graphics.h>
  13.  
  14. int huge DetectVGA256(void)
  15. {
  16.  return(0);   /* change 0 to other value for SVGA modes */
  17. }
  18.  
  19. void setvga256(void)
  20. {
  21.  int gm,driver = DETECT;
  22.  installuserdriver("svga256",DetectVGA256);
  23.  initgraph(&driver,&gm,"");
  24. }
  25.  
  26. void setvga16()
  27. {
  28.  int driver = VGA,
  29.      mode = VGALO;
  30.  
  31.  initgraph(&driver, &mode, "");
  32. }
  33.  
  34. void read_xgf(int x, int y, char *filename)
  35. {
  36.   char *imgBuf;
  37.   FILE *F;
  38.   unsigned int size;
  39.  
  40.   F=fopen(filename,"rb");
  41.   if (F!=NULL)
  42.   {
  43.    size=filelength(fileno(F));
  44.    imgBuf=malloc(size);
  45.    fread(imgBuf,size,1,F);
  46.    fclose(F);
  47.    putimage(x,y,imgBuf,COPY_PUT);
  48.    free(imgBuf);
  49.   }
  50. }
  51.  
  52. void main()
  53. {
  54.   setvga16();          /* replace with setvga256 for 256 color XGF files */
  55.   setfillstyle(SOLID_FILL,BLUE);
  56.   bar(0,0,getmaxx(),getmaxy());
  57.   read_xgf(0,0,"image2.xgf");
  58.   getch();
  59.   closegraph();
  60. }
  61.